package 题目集.前缀和.二维前缀和;

import java.io.*;
import java.util.StringTokenizer;

public class 最大子矩阵和 {

    static int n, m;
    static long[][] sum;
    static PrintWriter pr=new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));

    public static void main(String[] args) {
        Reader sc = new Reader();
        n = sc.nextInt();
        m = sc.nextInt();
        sum = new long[n + 1][m + 1];
        for (int i = 1; i <= n; i++) {
            for (int j = 1; j <= m; j++) {
                sum[i][j] = sc.nextInt();
                sum[i][j] += sum[i][j - 1] + sum[i - 1][j] - sum[i - 1][j - 1];
            }
        }
        long res = 0;
        long temp;
        for (int i = n; i > 0; i--) {
            for (int j = m; j > 0; j--) {
                for (int dx = 0; dx < i; dx++) {
                    for (int dy = 0; dy < j; dy++) {
                        temp = sum[i][j] - sum[i - dx - 1][j] - sum[i][j - dy - 1] + sum[i - dx - 1][j - dy - 1];
                        res = Math.max(res, temp);
                    }
                }
            }
        }
        pr.println(res);
        pr.flush();
    }
    static
    class Reader {
        private BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        private StringTokenizer tokenizer = new StringTokenizer("");

        private String innerNextLine() {
            try {
                return reader.readLine();
            } catch (IOException ex) {
                return null;
            }
        }

        public boolean hasNext() {
            while (!tokenizer.hasMoreTokens()) {    //内存中没有
                String nextLine = innerNextLine();
                if (nextLine == null) {     //且没有下一行
                    return false;
                }
                tokenizer = new StringTokenizer(nextLine);  //读入一行
            }
            return true;
        }

        public String nextLine() {
            tokenizer = new StringTokenizer("");    //清空内存中的字符
            return innerNextLine();
        }
        public void clear(){
            tokenizer = new StringTokenizer("");
        }

        public String next() {
            hasNext();
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

        public double nextDouble(){
            return Double.parseDouble(next());
        }
//    public BigInteger nextBigInt() {
//        return new BigInteger(next());
//    }
    }

}
